package algorithms;

import java.util.ArrayList;
import java.util.Comparator;

import base.GenericSearch;
import datastructures.MyNode;

public class DepthSearchLimited extends GenericSearch  {
	int maxSearchDepth;

	public DepthSearchLimited(Comparator<MyNode> comp, int maxSearchDepth) {
		super(comp);
		this.maxSearchDepth = maxSearchDepth;
	}

	//fuegt die nodes zu beginn der openlist ein
	@Override
	public void insert(ArrayList<MyNode> nodes) {
		ArrayList<MyNode> childs = new ArrayList<MyNode>();
		
		for (MyNode child : nodes) {
			if (child.getTiefe() < this.maxSearchDepth) {
				childs.add(child);

			}
			
		}
		this.openlist.addFirst(childs);
		
	}
	
	@Override
	public MyNode investigate() {
		return this.openlist.getFirstNode();
		
	}

}
